<include file="Public:header" />
<form action="" method="" class="definewidth m20" id="contract-form">
    <table class="table table-bordered table-hover definewidth m10">
        <tr>
            <td width="10%" class="tableleft">合同编号</td>
            <td><input type="text" name="contract_id"/></td>
        </tr>
        <tr>
            <td class="tableleft">企业名称</td>
            <td><input type="text" name="company_name"/></td>
        </tr>
        <tr>
            <td class="tableleft">合同金额</td>
            <td><input type="text" name="amount"/></td>
        </tr>

        <tr>
            <td class="tableleft">签订日期</td>
            <td><input type="date" name="make_time" value="{$now}"/></td>
        </tr>
        <tr>
            <td class="tableleft">合同截至日期</td>
            <td><input type="date" name="end_time" value="{$now}" /></td>
        </tr>
        <tr>
            <td class="tableleft">合同内容</td>
            <td><input type="text" name="content"/></td>
        </tr>
        <tr>
            <td class="tableleft">其他信息</td>
            <td><input type="text" name="extern"/></td>
        </tr>
        <tr>
            <td class="tableleft"></td>
            <td>
                <button type="button" class="btn btn-primary" type="button" id="add-contract">保存</button> &nbsp;&nbsp;<button type="button" class="btn btn-success" name="backid" id="backid">返回列表</button>
            </td>
        </tr>
    </table>
</form>

<script>
    $(function () {
        $('#backid').click(function(){
            window.location.href="{:U('Contract/Index')}";
        });
        $("#add-contract").click(function () {
            data = $("#contract-form").serialize();
            $.post(
                    "{:U('Contract/save')}",
                    data,
                    function(xhr){
                        if(200 == xhr.status){
                            alert(xhr.msg);
                            location.href = "{:U('Contract/Index')}"
                        }else {
                            alert(xhr.msg);
                        }
                    }
            );
        });

    });
</script>

<include file="Public:footer" />